.class public Lorg/zeam/WallpaperChooser;
.super Landroid/app/Activity;
.source "WallpaperChooser.java"

# interfaces
.implements Landroid/widget/AdapterView$OnItemSelectedListener;
.implements Landroid/view/View$OnClickListener;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lorg/zeam/WallpaperChooser$ImageAdapter;,
        Lorg/zeam/WallpaperChooser$WallpaperLoader;
    }
.end annotation

.annotation system Ldalvik/annotation/Signature;
    value = {
        "Landroid/app/Activity;",
        "Landroid/widget/AdapterView$OnItemSelectedListener;",
        "Landroid/view/View$OnClickListener;"
    }
.end annotation


# instance fields
.field private mBitmap:Landroid/graphics/Bitmap;

.field private mGallery:Landroid/widget/Gallery;

.field private mImageView:Landroid/widget/ImageView;

.field private mImages:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/ArrayList",
            "<",
            "Ljava/lang/Integer;",
            ">;"
        }
    .end annotation
.end field

.field private mIsWallpaperSet:Z

.field private mLoader:Lorg/zeam/WallpaperChooser$WallpaperLoader;

.field private mThumbs:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/ArrayList",
            "<",
            "Ljava/lang/Integer;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method public constructor <init>()V
    .locals 0

    .prologue
    .line 25
    invoke-direct {p0}, Landroid/app/Activity;-><init>()V

    return-void
.end method

.method static synthetic access$0(Lorg/zeam/WallpaperChooser;)Ljava/util/ArrayList;
    .locals 1
    .parameter

    .prologue
    .line 31
    iget-object v0, p0, Lorg/zeam/WallpaperChooser;->mThumbs:Ljava/util/ArrayList;

    return-object v0
.end method

.method static synthetic access$1(Lorg/zeam/WallpaperChooser;)Ljava/util/ArrayList;
    .locals 1
    .parameter

    .prologue
    .line 32
    iget-object v0, p0, Lorg/zeam/WallpaperChooser;->mImages:Ljava/util/ArrayList;

    return-object v0
.end method

.method static synthetic access$2(Lorg/zeam/WallpaperChooser;)Landroid/graphics/Bitmap;
    .locals 1
    .parameter

    .prologue
    .line 27
    iget-object v0, p0, Lorg/zeam/WallpaperChooser;->mBitmap:Landroid/graphics/Bitmap;

    return-object v0
.end method

.method static synthetic access$3(Lorg/zeam/WallpaperChooser;)Landroid/widget/ImageView;
    .locals 1
    .parameter

    .prologue
    .line 29
    iget-object v0, p0, Lorg/zeam/WallpaperChooser;->mImageView:Landroid/widget/ImageView;

    return-object v0
.end method

.method static synthetic access$4(Lorg/zeam/WallpaperChooser;Landroid/graphics/Bitmap;)V
    .locals 0
    .parameter
    .parameter

    .prologue
    .line 27
    iput-object p1, p0, Lorg/zeam/WallpaperChooser;->mBitmap:Landroid/graphics/Bitmap;

    return-void
.end method

.method static synthetic access$5(Lorg/zeam/WallpaperChooser;Lorg/zeam/WallpaperChooser$WallpaperLoader;)V
    .locals 0
    .parameter
    .parameter

    .prologue
    .line 33
    iput-object p1, p0, Lorg/zeam/WallpaperChooser;->mLoader:Lorg/zeam/WallpaperChooser$WallpaperLoader;

    return-void
.end method

.method private addWallpapers(Landroid/content/res/Resources;Ljava/lang/String;I)V
    .locals 8
    .parameter "resources"
    .parameter "packageName"
    .parameter "list"

    .prologue
    .line 64
    invoke-virtual {p1, p3}, Landroid/content/res/Resources;->getStringArray(I)[Ljava/lang/String;

    move-result-object v1

    .line 65
    .local v1, extras:[Ljava/lang/String;
    array-length v4, v1

    const/4 v5, 0x0

    :goto_0
    if-lt v5, v4, :cond_0

    .line 75
    return-void

    .line 65
    :cond_0
    aget-object v0, v1, v5

    .line 66
    .local v0, extra:Ljava/lang/String;
    const-string v6, "drawable"

    invoke-virtual {p1, v0, v6, p2}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I

    move-result v2

    .line 67
    .local v2, res:I
    if-eqz v2, :cond_1

    .line 68
    new-instance v6, Ljava/lang/StringBuilder;

    invoke-static {v0}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v7

    invoke-direct {v6, v7}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v7, "_small"

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v6

    const-string v7, "drawable"

    invoke-virtual {p1, v6, v7, p2}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I

    move-result v3

    .line 69
    .local v3, thumbRes:I
    if-eqz v3, :cond_1

    .line 70
    iget-object v6, p0, Lorg/zeam/WallpaperChooser;->mThumbs:Ljava/util/ArrayList;

    invoke-static {v3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v7

    invoke-virtual {v6, v7}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 71
    iget-object v6, p0, Lorg/zeam/WallpaperChooser;->mImages:Ljava/util/ArrayList;

    invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v7

    invoke-virtual {v6, v7}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 65
    .end local v3           #thumbRes:I
    :cond_1
    add-int/lit8 v5, v5, 0x1

    goto :goto_0
.end method

.method private findWallpapers()V
    .locals 4

    .prologue
    const/16 v3, 0x18

    .line 54
    new-instance v2, Ljava/util/ArrayList;

    invoke-direct {v2, v3}, Ljava/util/ArrayList;-><init>(I)V

    iput-object v2, p0, Lorg/zeam/WallpaperChooser;->mThumbs:Ljava/util/ArrayList;

    .line 55
    new-instance v2, Ljava/util/ArrayList;

    invoke-direct {v2, v3}, Ljava/util/ArrayList;-><init>(I)V

    iput-object v2, p0, Lorg/zeam/WallpaperChooser;->mImages:Ljava/util/ArrayList;

    .line 56
    invoke-virtual {p0}, Lorg/zeam/WallpaperChooser;->getResources()Landroid/content/res/Resources;

    move-result-object v1

    .line 57
    .local v1, resources:Landroid/content/res/Resources;
    invoke-virtual {p0}, Lorg/zeam/WallpaperChooser;->getApplication()Landroid/app/Application;

    move-result-object v2

    invoke-virtual {v2}, Landroid/app/Application;->getPackageName()Ljava/lang/String;

    move-result-object v0

    .line 58
    .local v0, packageName:Ljava/lang/String;
    const v2, 0x7f090009

    invoke-direct {p0, v1, v0, v2}, Lorg/zeam/WallpaperChooser;->addWallpapers(Landroid/content/res/Resources;Ljava/lang/String;I)V

    .line 59
    const/high16 v2, 0x7f09

    invoke-direct {p0, v1, v0, v2}, Lorg/zeam/WallpaperChooser;->addWallpapers(Landroid/content/res/Resources;Ljava/lang/String;I)V

    .line 60
    return-void
.end method

.method private selectWallpaper(I)V
    .locals 5
    .parameter "position"

    .prologue
    .line 102
    iget-boolean v2, p0, Lorg/zeam/WallpaperChooser;->mIsWallpaperSet:Z

    if-eqz v2, :cond_0

    .line 115
    :goto_0
    return-void

    .line 105
    :cond_0
    const/4 v2, 0x1

    iput-boolean v2, p0, Lorg/zeam/WallpaperChooser;->mIsWallpaperSet:Z

    .line 107
    :try_start_0
    const-string v2, "wallpaper"

    invoke-virtual {p0, v2}, Lorg/zeam/WallpaperChooser;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Landroid/app/WallpaperManager;

    .line 108
    .local v1, wallpaperManager:Landroid/app/WallpaperManager;
    iget-object v2, p0, Lorg/zeam/WallpaperChooser;->mImages:Ljava/util/ArrayList;

    invoke-virtual {v2, p1}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/lang/Integer;

    invoke-virtual {v2}, Ljava/lang/Integer;->intValue()I

    move-result v2

    invoke-virtual {v1, v2}, Landroid/app/WallpaperManager;->setResource(I)V

    .line 109
    const/4 v2, -0x1

    invoke-virtual {p0, v2}, Lorg/zeam/WallpaperChooser;->setResult(I)V

    .line 110
    invoke-virtual {p0}, Lorg/zeam/WallpaperChooser;->finish()V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 112
    .end local v1           #wallpaperManager:Landroid/app/WallpaperManager;
    :catch_0
    move-exception v2

    move-object v0, v2

    .line 113
    .local v0, e:Ljava/io/IOException;
    sget-object v2, Lorg/zeam/Launcher;->LOG_TAG:Ljava/lang/String;

    new-instance v3, Ljava/lang/StringBuilder;

    const-string v4, "Failed to set wallpaper: "

    invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-static {v2, v3}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_0
.end method


# virtual methods
.method public onClick(Landroid/view/View;)V
    .locals 1
    .parameter "v"

    .prologue
    .line 162
    iget-object v0, p0, Lorg/zeam/WallpaperChooser;->mGallery:Landroid/widget/Gallery;

    invoke-virtual {v0}, Landroid/widget/Gallery;->getSelectedItemPosition()I

    move-result v0

    invoke-direct {p0, v0}, Lorg/zeam/WallpaperChooser;->selectWallpaper(I)V

    .line 163
    return-void
.end method

.method public onCreate(Landroid/os/Bundle;)V
    .locals 2
    .parameter "icicle"

    .prologue
    .line 38
    invoke-super {p0, p1}, Landroid/app/Activity;->onCreate(Landroid/os/Bundle;)V

    .line 39
    const/4 v0, 0x1

    invoke-virtual {p0, v0}, Lorg/zeam/WallpaperChooser;->requestWindowFeature(I)Z

    .line 40
    invoke-direct {p0}, Lorg/zeam/WallpaperChooser;->findWallpapers()V

    .line 42
    const v0, 0x7f030017

    invoke-virtual {p0, v0}, Lorg/zeam/WallpaperChooser;->setContentView(I)V

    .line 43
    const v0, 0x7f060026

    invoke-virtual {p0, v0}, Lorg/zeam/WallpaperChooser;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/Gallery;

    iput-object v0, p0, Lorg/zeam/WallpaperChooser;->mGallery:Landroid/widget/Gallery;

    .line 44
    iget-object v0, p0, Lorg/zeam/WallpaperChooser;->mGallery:Landroid/widget/Gallery;

    new-instance v1, Lorg/zeam/WallpaperChooser$ImageAdapter;

    invoke-direct {v1, p0, p0}, Lorg/zeam/WallpaperChooser$ImageAdapter;-><init>(Lorg/zeam/WallpaperChooser;Lorg/zeam/WallpaperChooser;)V

    invoke-virtual {v0, v1}, Landroid/widget/Gallery;->setAdapter(Landroid/widget/SpinnerAdapter;)V

    .line 45
    iget-object v0, p0, Lorg/zeam/WallpaperChooser;->mGallery:Landroid/widget/Gallery;

    invoke-virtual {v0, p0}, Landroid/widget/Gallery;->setOnItemSelectedListener(Landroid/widget/AdapterView$OnItemSelectedListener;)V

    .line 46
    iget-object v0, p0, Lorg/zeam/WallpaperChooser;->mGallery:Landroid/widget/Gallery;

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Landroid/widget/Gallery;->setCallbackDuringFling(Z)V

    .line 48
    const v0, 0x7f060027

    invoke-virtual {p0, v0}, Lorg/zeam/WallpaperChooser;->findViewById(I)Landroid/view/View;

    move-result-object v0

    invoke-virtual {v0, p0}, Landroid/view/View;->setOnClickListener(Landroid/view/View$OnClickListener;)V

    .line 49
    const v0, 0x7f060025

    invoke-virtual {p0, v0}, Lorg/zeam/WallpaperChooser;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/ImageView;

    iput-object v0, p0, Lorg/zeam/WallpaperChooser;->mImageView:Landroid/widget/ImageView;

    .line 50
    return-void
.end method

.method protected onDestroy()V
    .locals 2

    .prologue
    .line 86
    invoke-super {p0}, Landroid/app/Activity;->onDestroy()V

    .line 87
    iget-object v0, p0, Lorg/zeam/WallpaperChooser;->mLoader:Lorg/zeam/WallpaperChooser$WallpaperLoader;

    if-eqz v0, :cond_0

    iget-object v0, p0, Lorg/zeam/WallpaperChooser;->mLoader:Lorg/zeam/WallpaperChooser$WallpaperLoader;

    invoke-virtual {v0}, Lorg/zeam/WallpaperChooser$WallpaperLoader;->getStatus()Landroid/os/AsyncTask$Status;

    move-result-object v0

    sget-object v1, Landroid/os/AsyncTask$Status;->FINISHED:Landroid/os/AsyncTask$Status;

    if-eq v0, v1, :cond_0

    .line 88
    iget-object v0, p0, Lorg/zeam/WallpaperChooser;->mLoader:Lorg/zeam/WallpaperChooser$WallpaperLoader;

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Lorg/zeam/WallpaperChooser$WallpaperLoader;->cancel(Z)Z

    .line 89
    const/4 v0, 0x0

    iput-object v0, p0, Lorg/zeam/WallpaperChooser;->mLoader:Lorg/zeam/WallpaperChooser$WallpaperLoader;

    .line 91
    :cond_0
    return-void
.end method

.method public onItemSelected(Landroid/widget/AdapterView;Landroid/view/View;IJ)V
    .locals 4
    .parameter "parent"
    .parameter "v"
    .parameter "position"
    .parameter "id"

    .prologue
    .line 94
    iget-object v0, p0, Lorg/zeam/WallpaperChooser;->mLoader:Lorg/zeam/WallpaperChooser$WallpaperLoader;

    if-eqz v0, :cond_0

    iget-object v0, p0, Lorg/zeam/WallpaperChooser;->mLoader:Lorg/zeam/WallpaperChooser$WallpaperLoader;

    invoke-virtual {v0}, Lorg/zeam/WallpaperChooser$WallpaperLoader;->getStatus()Landroid/os/AsyncTask$Status;

    move-result-object v0

    sget-object v1, Landroid/os/AsyncTask$Status;->FINISHED:Landroid/os/AsyncTask$Status;

    if-eq v0, v1, :cond_0

    .line 95
    iget-object v0, p0, Lorg/zeam/WallpaperChooser;->mLoader:Lorg/zeam/WallpaperChooser$WallpaperLoader;

    invoke-virtual {v0}, Lorg/zeam/WallpaperChooser$WallpaperLoader;->cancel()V

    .line 97
    :cond_0
    new-instance v0, Lorg/zeam/WallpaperChooser$WallpaperLoader;

    invoke-direct {v0, p0}, Lorg/zeam/WallpaperChooser$WallpaperLoader;-><init>(Lorg/zeam/WallpaperChooser;)V

    const/4 v1, 0x1

    new-array v1, v1, [Ljava/lang/Integer;

    const/4 v2, 0x0

    invoke-static {p3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v3

    aput-object v3, v1, v2

    invoke-virtual {v0, v1}, Lorg/zeam/WallpaperChooser$WallpaperLoader;->execute([Ljava/lang/Object;)Landroid/os/AsyncTask;

    move-result-object v0

    check-cast v0, Lorg/zeam/WallpaperChooser$WallpaperLoader;

    iput-object v0, p0, Lorg/zeam/WallpaperChooser;->mLoader:Lorg/zeam/WallpaperChooser$WallpaperLoader;

    .line 98
    return-void
.end method

.method public onNothingSelected(Landroid/widget/AdapterView;)V
    .locals 0
    .parameter "parent"

    .prologue
    .line 118
    return-void
.end method

.method protected onResume()V
    .locals 1

    .prologue
    .line 79
    invoke-super {p0}, Landroid/app/Activity;->onResume()V

    .line 80
    const/4 v0, 0x0

    iput-boolean v0, p0, Lorg/zeam/WallpaperChooser;->mIsWallpaperSet:Z

    .line 81
    return-void
.end method
